home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / progs / editor / frexxed / fpl / ccalc.fpl < prev    next >
Text File  |  1995-08-22  |  866b  |  38 lines

  1.  
  2. string history_list[20];
  3. int history_items;
  4.  
  5. export int cCalcresult;
  6.  
  7. export void cCalc()
  8. {
  9.   string expression;
  10.   int list=history_items;
  11.   if(!list) {
  12.     list=1;
  13.     history_list[0]=" ";
  14.   }
  15.   if(RequestWindow("Expression",
  16.                    "C-style expression", "a", &history_list, &expression,
  17.                    list)) {
  18.     if(!ExecuteString(sprintf("cCalcresult = %s;", expression))) {
  19.       Request(sprintf("%s =\n\nDec: %d\nHex: %X\nBin: %b\nOct: %o",
  20.                       expression,
  21.                       cCalcresult, cCalcresult, cCalcresult, cCalcresult),
  22.               "Result", "Wow!");
  23.     }
  24.     if(history_items++) {
  25.       int a;
  26.       if(history_items>20)
  27.         history_items--;
  28.  
  29.       a = history_items-1;
  30.       while(a>0) {
  31.         history_list [a] = history_list [a-1];
  32.         a--;
  33.       }
  34.     }
  35.     history_list [0] = expression;
  36.   }
  37. }
  38.